home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
datescrn.arc
/
CURSOR.C
< prev
next >
Wrap
Text File
|
1985-12-12
|
3KB
|
175 lines
/*---------------------------------------------------------------------
*
* C U R S O R
*
*----------------------------------------------------------------------
*
* Name: curpos
* Name: cwrite
* Name: putspec
* Name: getcurs
*
*/
#include <stdio.h>
struct regval {
int ax;
int bx;
int cx;
int dx;
int si;
int di;
int ds;
int es;
};
static struct regval cursout;
/*-
* Name: curpos Origin: wrb 04/04/83
*
* Abstract: Position cursor on IBM PC
*
* Description:
*
* Values from 0 - 24 valid for x, 0 - 79 valid for y
*/
curpos(row, col)
register short row, col;
{
struct regval curs;
curs.bx = 0; /* set text page number */
curs.ax = 2;
curs.ax <<= 8; /* set function to set cursor */
curs.dx = row;
curs.dx <<= 8; /* lay in row */
curs.dx |= col; /* lay in column */
sysint(0x10, &curs, &curs); /* put cursor at position */
}
/*-
* Name: cwrite Origin: wrb 04/04/83
*
* Abstract: Write specified character cnt # of times
*
* Description:
*
* Useful for clearing lines, screen
*/
cwrite(ch, cnt)
register short ch, cnt;
{
struct regval curs;
curs.bx = 7; /* set text page number/attribute */
curs.ax = 0x900;
curs.cx = cnt; /* # characters to write */
curs.ax |= (char)ch;
sysint(0x10, &curs, &curs); /* Write the character(s) */
}
/*-
* Name: putspec Origin: wrb 04/13/83
*
* Abstract: Output string in modified video
*
* Description:
*
* Strings must be NULL terminated.
*/
putspec(attrib, s)
register short attrib;
register char *s;
{
short row, col, oldrow, oldcol;
struct regval spccurs;
spccurs.bx = attrib; /* set text page number/attribute */
spccurs.cx = 1; /* # characters to write */
spccurs.ax = 0x900;
sysint(0x10, &spccurs, &cursout);
while(*s) {
bdos(6,*s++);
if(*s) sysint(0x10, &spccurs, &cursout); /* Write the character */
}
}
/*-
* Name: getcurs Origin: wrb
*
* Abstract: Get current cursor position
*
* Description:
*
* Use system interrupt 10 (hex)
*/
getcurs(row, col)
register short *row, *col;
{
struct regval getcur;
getcur.ax = 0x300;
getcur.bx = 0;
sysint(0x10, &getcur, &getcur); /* get current cursor pos */
*row = ((getcur.dx >> 8) & 0xff);
*col = getcur.dx & 0xff;
}
/*-
* Name: scrolldwn Origin: wrb 04/04/83
*
* Abstract: Scroll screen down at specified row, col
*
* Description:
*
* Scrolls from row, col to line 22.
*/
scrolldwn(row, col)
register short row, col;
{
struct regval scr;
scr.ax = 0x0701; /* Blank one line */
scr.bx = 0x0700; /* Attrib for blank line */
scr.cx = row;
scr.cx <<= 8;
scr.cx |= col;
scr.dx = 22;
scr.dx <<= 8; /* lay in row */
scr.dx |= 79; /* lay in column */
sysint(0x10, &scr, &scr); /* Scroll the screen */
}
/*-
* Name: scrollup Origin: wrb 04/04/83
*
* Abstract: Scroll screen up at specified row, col
*
* Description:
*
* Scrolls from line 22, row 79 to row, col
*/
scrollup(row, col)
register short row, col;
{
struct regval scr;
scr.ax = 0x0601; /* Blank one line */
scr.bx = 0x0700; /* Attrib for blank line */
scr.cx = row;
scr.cx <<= 8;
scr.cx |= col;
scr.dx = 22;
scr.dx <<= 8; /* lay in row */
scr.dx |= 79; /* lay in column */
sysint(0x10, &scr, &scr); /* Scroll the screen */
}